package com.niit.bean;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class SchoolBean implements WritableComparable<SchoolBean> {
    private String City;//城市
    private String School;//学校
    private long ActiveDays;//活跃天数

    private static Map<String, Long> schoolActiveDaysSum = new HashMap<>();

    public SchoolBean() {
    }

    public SchoolBean(String City, String School, long ActiveDays) {
        this.City = City;
        this.School = School;
        this.ActiveDays = ActiveDays;

    }

    public void set (String City, String School, long ActiveDays) {
        this.City = City;
        this.School = School;
        this.ActiveDays = ActiveDays;

    }

    public String getCity() {
        return City;
    }

    public void setCity(String City) {
        this.City = City;
    }

    public String getSchool() {
        return School;
    }

    public void setSchool(String School) {
        this.School = School;
    }

    public long getActiveDays() {
        return ActiveDays;

    }

    public void setActiveDays(long ActiveDays) {
        this.ActiveDays = ActiveDays;

    }

    @Override
    public String toString() {
        return "城市："+City+",学校："+School+",活跃天数："+ActiveDays;
    }

    //todo 排序规则 根据州state正序进行排序 如果州相同 则根据确诊数量cases倒序排序


    @Override
    public int compareTo(SchoolBean o) {
        return this.ActiveDays - o.getActiveDays() > 0 ? -1 : (this.ActiveDays - o.getActiveDays() < 0 ? 1 : 0) ;
    }


    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(City);
        dataOutput.writeUTF(School);
        dataOutput.writeLong(ActiveDays);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.City =dataInput.readUTF();
        this.School =dataInput.readUTF();
        this.ActiveDays =dataInput.readLong();

    }




}
